package com.googlecode.beanfiles;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class DefaultTargetFactoryImpl<T> implements TargetFactory<T> {

    protected static Log log() {
        return LogFactory.getLog(DefaultTargetFactoryImpl.class);
    }

    Class<T> clazz = null;
    
    public DefaultTargetFactoryImpl(Class<T> clazz) {
        this.clazz = clazz;
    }

    public T createTarget() {
        try {
            return clazz.newInstance();
        } catch (InstantiationException e) {
            log().error(e);
            throw new TranslationException(e);
        } catch (IllegalAccessException e) {
            log().error(e);
            throw new TranslationException(e);
        }
    }

}
